package com.lingjtx.ai.controller;

import com.lingjtx.ai.service.FunctionCallService;
import com.lingjtx.common.core.model.api.OssUploadResponseItem;
import com.lingjtx.common.core.model.api.OssUploadStream;
import com.lingjtx.common.thread.api.WebClientApi;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Mono;

import java.nio.charset.StandardCharsets;

/**
 * Ai 函数调用（webhook 功能）
 */
@RestController
@RequestMapping("/webhook")
public class FunctionCallController {

    @Autowired
    private FunctionCallService functionCallService;

    @Autowired
    private WebClientApi webClientApi;

    /**
     * 合同审查批注(修改word文件)
     */
    @PostMapping("/contract/review")
    public Mono<String> contractReview() {
        return Mono.just("model");
    }

    /**
     * 文书起草(生成word文件)
     */
    @PostMapping("/contract/create")
    public Mono<OssUploadResponseItem> createContract() {
        OssUploadStream model = new OssUploadStream();
        model.setFileType(".txt");
        model.setFolderType(1);
        model.setInputBytes("hello world!".getBytes(StandardCharsets.UTF_8));
        return webClientApi.singleUpload(model);
    }
}
